//
//  ViewController.swift
//  GCD队列组函数-SwiftDemo
//
//  Created by 李煜 on 2024/5/20.
//

import UIKit

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        test1()
    }

    func test1() {
        let group = DispatchGroup()
//        let myQueue: DispatchQueue? = DispatchQueue.global()
        let myQueue: DispatchQueue? = .global(qos: .default)
        dispatch_queue_t(label: "abc", attributes: [.concurrent])

        myQueue?.async(group: group, qos: .default, flags: [], execute: {
            for _ in 0 ... 10000 {
                print("耗时任务1")
            }
        })
        myQueue?.async(group: group, qos: .default, flags: [], execute: {
            for _ in 0 ... 10000 {
                print("耗时任务2")
            }
        })
        // 执行完上面的两个耗时操作, 回到myQueue队列中执行下一步的任务
        group.notify(queue: myQueue!) {
            print("回到该队列中执行")
        }
    }
}
